public class Konwerter
{
	int number, temp;
	private String output;
	static String cyfry[]=
		{"0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"};
	
	Konwerter(int number) 
	{
		System.out.println("Tworze Konwertora dla "+number);
		this.number=number;
	}

	public String konwertuj(int baza) throws IndexOutOfBoundsException
	{
		if(baza<2 || baza>16)
		{
			System.out.println(baza+": blad");
			throw new IndexOutOfBoundsException("Blad: baza spoza zakresu 2-16");
		}
		
		temp=number;
		output="";
		
		while(temp>=1)
		{
			output=cyfry[temp%baza]+output;
			temp=temp/baza;
		}
		System.out.println(baza+": "+output);
		return output;
	}
}